//
//  extension+NSBundle.swift
//  MXWeiBo
//
//  Created by Apple on 16/2/26.
//  Copyright © 2016年 Applea. All rights reserved.
//

import Foundation
extension NSBundle {
 
//    获取当前版本号
    class var currentVersion : String {
        guard let currentVersion = NSBundle.mainBundle().infoDictionary?["CFBundleShortVersionString"]as?  String else
        {
            return "000.000.000"
        }
        
        //        拆分字符串 1 ／ 2 ／ 3
        let strs = currentVersion.componentsSeparatedByString(".")
        var array : [CVarArgType] = [0, 0, 0]
        
        //     遍历数组，生成临时数组
        for e in strs.enumerate() {
            array.insert(Int(e.element) ?? 0, atIndex: e.index)
        }
        
        print(array)
        
        //        格式化字符串 001.002.003
        return String(format: "%03d.%03d.%03d", arguments: array)
        
    }
    
}